package valueObject
{
	import com.greensock.TimelineLite;
	import com.greensock.TweenLite;
	
	import flash.events.Event;
	
	import util.ScreenUtil;

	/**
	 *子弹基类 
	 * @author SXT
	 */
	public class BulletVO extends BaseVO implements IVO
	{
		/**
		 *是否跟踪 
		 */
		public var follow:Boolean;
		/**
		 *初始攻击力 
		 */
		public var power:int;
		/**
		 *范围 
		 */
		public var range:int;
		/**
		 *子弹类型 
		 */		
		public var type:int;
		/**
		 *是否重复伤害 
		 */
		public var repeat:Array = [];
		/**
		 *子弹速度 
		 */
		public var speed:int;
		/**
		 *是否群伤（伤害的个数） 
		 */
		public var more:int;
		/**
		 *是否处在活动状态 
		 */
		public var isActivity:Boolean = false;
		/**
		 *攻击的目标 
		 */		
		public var target:BaseVO;
		
		public var timeLine:TimelineLite;
	
		public function BulletVO()
		{
			super();
			timeLine = new TimelineLite();
			this.mouseChildren = false;
			this.mouseEnabled = false;
		}
		/**
		 *碰撞到怪物后执行 
		 * 播放动画
		 * 回收资源
		 */		
		public function hide():void
		{
			isActivity = false;
		}
		/**
		 * 移动到目标
		 */		
		public function gotoTarget():void
		{
			mc.rotation = ScreenUtil.getRotation(target.x - x,target.y - y);
			timeLine.append(TweenLite.to(this,speed,{x:target.x, y:target.y,onComplete:completeHandler}));
		}
		
		private function completeHandler(e:Event = null):void{
			if(this.parent && this.parent.contains(this)){
				this.parent.removeChild(this);
			}
			hide();
		}
		
		public function release():void
		{
			hide();
			mc.gotoAndStop(1);
			timeLine.reverse();
		}
	}
}